/*
Nuno
Generative circles for Piccolo App
dots along the circles are drawing points for the Piccolo, the radius of the dots represents the Z value
smaller dots make thin stroke; larger make thick stroke
Feb 7
*/

import controlP5.*;

ControlP5 controlP5;
ControlWindow controlWindow;

CircleList circles; //store all circles

void setup() {
  size(400,400);
  smooth();
  initializeControlP5();
  circles = new CircleList();
}

void draw() {
  background(255);
  circles.draw();
}

void controlEvent(ControlEvent theEvent) {
  switch(theEvent.controller().id()) {
    case(0):
      circles = new CircleList();  //renew the CircleList
      break;
    case(1):
      circles.shuffle();  //shuffle exsited circles
      break;
    case(2):
      circles.setShowMode(2);  //display drawing dots
      circles.draw();
      break;
    case(3):
      circles.setShowMode(0);  //turn off drawing dots
      circles.draw();
      break;
  }
}

void initializeControlP5() {  // initialize control menu
  controlP5 = new ControlP5(this);
  controlP5.setAutoDraw(false);
  controlWindow = controlP5.addControlWindow("controlP5window", 100,100,300,150);  
  controlWindow.hideCoordinates();
  controlWindow.setBackground(color(200));
  controlWindow.setTitle("Controller");
  
  Controller newBtn = controlP5.addButton("New", 0, 20,100,50,20);
  newBtn.setWindow(controlWindow);
  newBtn.setId(0);
  
  Controller shuffleBtn = controlP5.addButton("Shuffle",1,20+50+20,100,50,20);  
  shuffleBtn.setId(1);
  shuffleBtn.setWindow(controlWindow);    
  
  Controller dotBtn = controlP5.addButton("ShowDot", 2, 20+50+20+50+20, 100, 50, 20);
  dotBtn.setId(2);
  dotBtn.setWindow(controlWindow);
  
  Controller noDotBtn = controlP5.addButton("NoDot", 3, 20+50+20+50+20+50+20, 100, 50, 20);
  noDotBtn.setId(3);
  noDotBtn.setWindow(controlWindow);
}
